package com.briup.ptp.web.controller;

import com.briup.ptp.entity.Lifetime;
import com.briup.ptp.service.LifetimeService;
import com.briup.ptp.utils.Result;
import com.github.pagehelper.PageInfo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
//处理路径
@RequestMapping("/lifetime")
@Api(tags="溯源管理")
public class LifetimeController {

    @Autowired
    private LifetimeService service;

    //查询信息
    @PostMapping("/traceProduct")
    @ApiOperation("分页查询生猪信息")
    //接口的参数列表
    @ApiImplicitParams(
            {
                    @ApiImplicitParam(name="pageNum",value="当前页码",required = true),
                    @ApiImplicitParam(name="pageSize",value="每页大小",required = true)

            }
    )
    public Result traceProduct(Integer pageNum, Integer pageSize){
        //调用 LifetimeService 中的 traceProduct 方法，传入页面大小和页码参       数，用于查询生猪信息。
        PageInfo<Lifetime> pigs=service.traceProduct(pageSize,pageNum);
        return Result.success(pigs);
    }




}
